package com.jic.manager.impl;

import java.lang.Long;
import java.util.List;

import com.jic.manager.entity.SysMenu;
import com.jic.manager.entity.SysRoleMenu;
import com.jic.manager.mapper.SysMenuMapper;
import com.jic.manager.request.SysRoleMenuRequest;
import com.jic.manager.service.SysMenuService;
import com.jic.common.base.vo.Page;
import com.jic.common.base.vo.PageResult;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 菜单资源信息表
 * @author : 
 * @email : 
 * @since : 2020-02-26 09:39:25
 * @version : v1.0.0
 */
@Service
public class SysMenuServiceImpl implements SysMenuService{

    @Resource
    private SysMenuMapper sysMenuMapper;

    @Override
    public long insert(SysMenu sysMenu) {
        long flag = sysMenuMapper.insert(sysMenu);
        return flag;
    }

    @Override
    public long delete(Long id) {
        return sysMenuMapper.delete(id);
    }

    @Override
    public long update(SysMenu sysMenu) {
        return sysMenuMapper.update(sysMenu);
    }

    @Override
    public SysMenu queryByPrimaryKey(Long id){
        return sysMenuMapper.queryByPrimaryKey(id);
    }

    @Override
    public List<SysMenu> query(SysMenu sysMenu){
        return sysMenuMapper.query(sysMenu);
    }

    @Override
    public PageResult<SysMenu> queryPage(SysMenu sysMenu, Page pageQuery) {
        //计算下标
        int startIndex = (pageQuery.getStart() - 1) * pageQuery.getLimit();
        List<SysMenu> list = sysMenuMapper.queryPage(startIndex, pageQuery.getLimit(), sysMenu);
        long count = sysMenuMapper.queryPageCount(sysMenu);
        PageResult pageResult = new PageResult();
        pageResult.setRows(list);
        pageResult.setTotal(count);
        return pageResult;
    }

    @Override
    public List<SysMenu> findPermissions(SysRoleMenuRequest sysRoleMenuRequest) {
        return sysMenuMapper.findPermissions(sysRoleMenuRequest);
    }


    @Override
    public List<SysMenu> getRoleMenuListByRoleid(SysRoleMenuRequest sysRoleMenuRequest) {
        return sysMenuMapper.getRoleMenuListByRoleid(sysRoleMenuRequest);
    }
}